﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics.Metrics;
using System.Drawing;
using System.Linq;
using System.Security;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using Traceability.Commont.Domains;

namespace Butcher.winform.EnterpriseForms.RBAC
{
    public partial class permissionAdd : Form
    {
        public permissionAdd()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string urr = @"http://localhost:5021/api/Trace/AddPermissions";
            HttpClient client = new HttpClient();
            Permissions permissions = new Permissions();
            permissions.PermissionsName=textBox1.Text;
            permissions.PermissionsURL=textBox2.Text;
            permissions.PermissionsNo=textBox3.Text;
            permissions.PermissionsId = 0;
            permissions.Pid = 0;
            var content = new StringContent(JsonSerializer.Serialize<Permissions>(permissions));
            content.Headers.Remove("Content-Type");
            content.Headers.Add("Content-Type", "application/json");
            string result = client.PostAsync(urr, content).Result.Content.ReadAsStringAsync().Result;
            if (result != null)
            {
                MessageBox.Show("新增成功");

            }

        }
    }
}
